var entry = {
  a: {
    b: {
      c: {
        dd: "abcdd",
      },
    },
    d: {
      xx: "adxx",
    },
    e: "ae",
  },
};

// 要求转换成如下对象
var output = {
  "a.b.c.dd": "abcdd",
  "a.d.xx": "adxx",
  "a.e": "ae",
};

const getType = (value) => {
  return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
};

const newObj = {};

const getNewObj = (entry) => {
  const newObj = {};

  const test = (obj, oldKey) => {
    let k = "";
    Object.keys(obj).forEach((key) => {
      const myKey = oldKey ? `${oldKey}.${key}` : `${key}`;
      if (getType(obj[key]) !== "object") {
        newObj[myKey] = obj[key];
      } else {
        test(obj[key], myKey);
      }
      k = myKey;
    });
    return k;
  };

  test(entry, "");

  return newObj;
};

console.log(getNewObj(entry));
